package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.DevicesGoodsMapper;
import org.linlinjava.litemall.db.dao.DevicesOrderMapper;
import org.linlinjava.litemall.db.domain.DevicesOrder;
import org.linlinjava.litemall.db.enums.OrderStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class DevicesOrderService {
    @Autowired
    private DevicesOrderMapper orderMapper;

    @Autowired
    private DevicesGoodsMapper goodsMapper;


    @Transactional
    public DevicesOrder createOrder(DevicesOrder order) {
        // 生成订单号（示例用时间戳，实际应使用分布式ID）
        order.setOrderNo("ORD" + System.currentTimeMillis());
        orderMapper.insert(order);
        return order;
    }


    public void updateOrderStatus(Integer orderId, OrderStatus status) {
        orderMapper.updateStatus(orderId, status);
    }


    public DevicesOrder getOrderById(Integer orderId) {
        return orderMapper.selectById(orderId);
    }
}
